IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:51:07 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO
print '[dbo].[Przesylki] dropped'

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:51:45 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Statusy]    Script Date: 12/03/2012 23:51:45 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Statusy]') AND type in (N'U'))
DROP TABLE [dbo].[Statusy]
GO
print '[dbo].[Statusy] dropped'


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Magazyny_Regiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Magazyny]'))
ALTER TABLE [dbo].[Magazyny] DROP CONSTRAINT [FK_Magazyny_Regiony]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:52:12 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Magazyny]    Script Date: 12/03/2012 23:52:12 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Magazyny]') AND type in (N'U'))
DROP TABLE [dbo].[Magazyny]
GO
print '[dbo].[Magazyny] dropped'


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Klienci_Subregiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Klienci]'))
ALTER TABLE [dbo].[Klienci] DROP CONSTRAINT [FK_Klienci_Subregiony]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Dostawcy]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Dostawcy]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Regiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Regiony]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:53:00 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Klienci]    Script Date: 12/03/2012 23:53:00 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Klienci]') AND type in (N'U'))
DROP TABLE [dbo].[Klienci]
GO

/****** Object:  Table [dbo].[Subregiony]    Script Date: 12/03/2012 23:53:00 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Subregiony]') AND type in (N'U'))
DROP TABLE [dbo].[Subregiony]
GO

/****** Object:  Table [dbo].[Dostawcy]    Script Date: 12/03/2012 23:53:00 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Dostawcy]') AND type in (N'U'))
DROP TABLE [dbo].[Dostawcy]
GO
print '[dbo].[Dostawcy] dropped'


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Klienci_Subregiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Klienci]'))
ALTER TABLE [dbo].[Klienci] DROP CONSTRAINT [FK_Klienci_Subregiony]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:53:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Klienci]    Script Date: 12/03/2012 23:53:32 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Klienci]') AND type in (N'U'))
DROP TABLE [dbo].[Klienci]
GO
print '[dbo].[Klienci] dropped'


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Klienci_Subregiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Klienci]'))
ALTER TABLE [dbo].[Klienci] DROP CONSTRAINT [FK_Klienci_Subregiony]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Dostawcy]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Dostawcy]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Regiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Regiony]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Magazyny_Regiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Magazyny]'))
ALTER TABLE [dbo].[Magazyny] DROP CONSTRAINT [FK_Magazyny_Regiony]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:54:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Klienci]    Script Date: 12/03/2012 23:54:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Klienci]') AND type in (N'U'))
DROP TABLE [dbo].[Klienci]
GO

/****** Object:  Table [dbo].[Subregiony]    Script Date: 12/03/2012 23:54:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Subregiony]') AND type in (N'U'))
DROP TABLE [dbo].[Subregiony]
GO

/****** Object:  Table [dbo].[Magazyny]    Script Date: 12/03/2012 23:54:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Magazyny]') AND type in (N'U'))
DROP TABLE [dbo].[Magazyny]
GO

/****** Object:  Table [dbo].[Regiony]    Script Date: 12/03/2012 23:54:04 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Regiony]') AND type in (N'U'))
DROP TABLE [dbo].[Regiony]
GO
print '[dbo].[Regiony] dropped'


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Dostawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Dostawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Magazyny]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Magazyny]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Nadawca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Nadawca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Odbiorca]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Odbiorca]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Przesylki_Status]') AND parent_object_id = OBJECT_ID(N'[dbo].[Przesylki]'))
ALTER TABLE [dbo].[Przesylki] DROP CONSTRAINT [FK_Przesylki_Status]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Klienci_Subregiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Klienci]'))
ALTER TABLE [dbo].[Klienci] DROP CONSTRAINT [FK_Klienci_Subregiony]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Dostawcy]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Dostawcy]
GO

IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Subregiony_Regiony]') AND parent_object_id = OBJECT_ID(N'[dbo].[Subregiony]'))
ALTER TABLE [dbo].[Subregiony] DROP CONSTRAINT [FK_Subregiony_Regiony]
GO

/****** Object:  Table [dbo].[Przesylki]    Script Date: 12/03/2012 23:54:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Przesylki]') AND type in (N'U'))
DROP TABLE [dbo].[Przesylki]
GO

/****** Object:  Table [dbo].[Klienci]    Script Date: 12/03/2012 23:54:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Klienci]') AND type in (N'U'))
DROP TABLE [dbo].[Klienci]
GO

/****** Object:  Table [dbo].[Subregiony]    Script Date: 12/03/2012 23:54:36 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Subregiony]') AND type in (N'U'))
DROP TABLE [dbo].[Subregiony]
GO
print '[dbo].[Subregiony] dropped'

/****** Object:  Table [dbo].[Nadzorcy]    Script Date: 01/06/2013 05:27:25 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Nadzorcy]') AND type in (N'U'))
DROP TABLE [dbo].[Nadzorcy]
GO
print '[dbo].[Nadzorcy] dropped'